home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Component;
- import java.awt.Cursor;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Label;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.event.MouseMotionListener;
- import java.net.URL;
-
- class Link extends Label implements MouseListener, MouseMotionListener, Runnable {
- ScrollBoxLink sbl;
- Font normalFont;
- Font enterFont;
- String link;
- String statusText;
- Thread thread;
- boolean move;
-
- public Link() {
- }
-
- public Link(String label, ScrollBoxLink sbl, String link, String status) {
- super(label);
- this.sbl = sbl;
- this.link = link;
- this.statusText = status;
- Font f = ((Component)this).getFont();
- String fontName = ((Applet)sbl).getParameter("text_font_name");
- if (fontName == null) {
- fontName = f.getName();
- }
-
- String s = ((Applet)sbl).getParameter("text_font_height");
- int textHeight;
- if (s != null) {
- textHeight = Integer.parseInt(s);
- } else {
- textHeight = 12;
- }
-
- s = ((Applet)sbl).getParameter("text_enter_font_height");
- int enterTextHeight;
- if (s != null) {
- enterTextHeight = Integer.parseInt(s);
- } else {
- enterTextHeight = textHeight;
- }
-
- int style = 0;
- s = ((Applet)sbl).getParameter("text_font_style");
- if (s != null) {
- if (s.equals("bold")) {
- style = 1;
- } else if (s.equals("italic")) {
- style = 2;
- } else if (s.equals("bold_italic")) {
- style = 3;
- } else {
- style = 0;
- }
- }
-
- int enterStyle = style;
- s = ((Applet)sbl).getParameter("text_enter_font_style");
- if (s != null) {
- if (s.equals("bold")) {
- enterStyle = 1;
- } else if (s.equals("italic")) {
- enterStyle = 2;
- } else if (s.equals("bold_italic")) {
- enterStyle = 3;
- }
- }
-
- try {
- this.normalFont = new Font(fontName, style, textHeight);
- this.enterFont = new Font(fontName, enterStyle, enterTextHeight);
- ((Component)this).setFont(this.normalFont);
- } catch (Exception var12) {
- this.normalFont = new Font(f.getName(), style, textHeight);
- this.enterFont = new Font(f.getName(), enterStyle, enterTextHeight);
- ((Component)this).setFont(this.normalFont);
- }
-
- if (sbl.justify == 1) {
- ((Label)this).setAlignment(1);
- }
-
- ((Component)this).addMouseListener(this);
- ((Component)this).addMouseMotionListener(this);
- ((Component)this).setForeground(sbl.normalColor);
- }
-
- public void start() {
- if (this.thread == null) {
- this.move = true;
- this.thread = new Thread(this);
- this.thread.start();
- }
-
- }
-
- public void stop() {
- if (this.thread != null) {
- this.move = false;
- this.thread = null;
- }
-
- }
-
- public void run() {
- this.move = true;
- int c = 1;
-
- while(this.move) {
- if (c == 0) {
- ((Component)this).setForeground(this.sbl.normalColor);
- } else {
- ((Component)this).setForeground(this.sbl.enterColor);
- }
-
- ((Component)this).repaint();
- c = 1 - c;
-
- try {
- Thread.sleep((long)this.sbl.pause);
- } catch (InterruptedException var2) {
- this.stop();
- }
- }
-
- this.stop();
- }
-
- public void update(Graphics g) {
- ((Component)this).paint(g);
- }
-
- public void mouseClicked(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- ((Component)this).setForeground(this.sbl.enterColor);
- ((Component)this).setFont(this.enterFont);
- if (this.statusText != null) {
- this.sbl.showStatus(this.statusText);
- }
-
- if (this.sbl.hand) {
- this.sbl.setCursor(new Cursor(12));
- }
-
- if (this.sbl.animated) {
- this.thread = new Thread(this);
- this.thread.start();
- }
-
- ((Component)this).repaint();
- }
-
- public void mouseExited(MouseEvent e) {
- if (this.sbl.animated) {
- this.move = false;
- }
-
- ((Component)this).setForeground(this.sbl.normalColor);
- ((Component)this).setFont(this.normalFont);
- if (this.sbl.hand) {
- this.sbl.setCursor(new Cursor(0));
- }
-
- ((Component)this).repaint();
- }
-
- public void mousePressed(MouseEvent e) {
- if (this.sbl.clicSound != null) {
- this.sbl.clicSound.play();
- }
-
- URL u = this.sbl.giveURL(this.link);
- String target = this.sbl.getParameter("target");
- if (target == null) {
- target = "_blank";
- }
-
- this.sbl.getAppletContext().showDocument(u, target);
- }
-
- public void mouseReleased(MouseEvent e) {
- }
-
- public void mouseDragged(MouseEvent e) {
- }
-
- public void mouseMoved(MouseEvent e) {
- }
- }
-